package com.sky.mapper;

import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: HuoXu
 * @Date: 2023/08/26/11:46
 * @Description: 快乐跳跳虎
 */
@Mapper
public interface ShoppingCartMapper {
    //添加购物车

    //添加购车前查询是否含有相同数据
    List<ShoppingCart> selectCart(ShoppingCart shoppingCart);
    //有相同数据时进行修改number的值
    @Update("update shopping_cart set number=#{number} where id=#{id}")
    void updateCart(ShoppingCart cart);
    //插入购物车
    @Insert("insert into shopping_cart" +
            "(name, image, user_id, dish_id, setmeal_id, dish_flavor, number, amount, create_time) " +
            "VALUES (#{name},#{image},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{createTime})")
    void addCart(ShoppingCart shoppingCart);

    @Select("select * from shopping_cart where user_id =#{currentId}")
    List<ShoppingCart> queryShoppingCart(Long currentId);

    void shoppingCartSub(ShoppingCart shoppingCart);

    void deleteCart(ShoppingCart shoppingCart);

    @Delete("delete from shopping_cart where user_id =#{currentId}")
    void shoppingCartClean(Long currentId);
    @Delete("delete from shopping_cart where user_id =#{currentId}")
    void deleteByUserId(Long currentId);
}
